import java.util.HashMap;
import java.util.HashSet;


class P11362_39643 {

    static String readLn() {
        String newLine = System.getProperty("line.separator");
        StringBuilder buffer = new StringBuilder();
        int car = -1;
        try {
            car = System.in.read();
            while ((car > 0) && (car != newLine.charAt(0))) {
                buffer.append((char) car);
                car = System.in.read();
            }
            if (car == newLine.charAt(0))
                System.in.skip(newLine.length() - 1);
        } catch (java.io.IOException e) {
            return (null);
        }
        if ((car < 0) && (buffer.length() == 0))
            return (null);
        return (buffer.toString()).trim();
    }
   
    public static void main(String[] args) {
        int cases = Integer.parseInt(readLn());
       
        for (int k = 0; k < cases; k++) {
            int number = Integer.parseInt(readLn());
           
            HashMap<String, Boolean> map = new HashMap<String, Boolean>();
           
            String[] words = new String[number];
            HashSet<Integer> lengths = new HashSet<Integer>();
           
            for (int m = 0; m < number; m++) {
                words[m] = readLn();
                map.put(words[m], Boolean.TRUE);
                lengths.add(words[m].length());
            }
           
            boolean consistent = true;
           
            for (int m = 0; m < number && consistent; m++) {
               
                for (int length : lengths) {
                   
                    String word = words[m];
                   
                    if (length < word.length()) {
                       
                        if (map.get(word.substring(0, length)) != null) {
                            consistent = false;
                            break;
                        }
                       
                    }
                   
                }
               
            }
           
           
//            boolean consistent = true;
//            for (int numberOfWords = 0; numberOfWords < number && consistent; numberOfWords++) {
//           
//                String l = readLn();
//               
//                for (int j = 1; j <= l.length(); j++) {
//                   
//                    String sub = l.substring(0, j);
//                   
//                    Boolean b = map.get(sub);
//                   
//                    if (b != null) {
//                        consistent = false;
//                        break;
//                    } else {
//                        map.put(sub, Boolean.TRUE);
//                    }
//                }
//            }
           
           
            System.out.println(consistent ? "YES" : "NO");
        }
    }
}